﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

using Castle.DynamicProxy;

using StructureMap.Configuration.DSL;
using StructureMap.Graph;

using ProjectBase.Core;

namespace Survey.Tools.IoC
{
    [CLSCompliant(false)]
    public class ProxyConvention : DefaultConventionScanner
    {
        public override void Process(Type type, Registry registry)
        {
            foreach (var inter in type.GetInterfaces()
                .Where(i => i.GetInterfaces().Any(t => t.IsEquivalentTo(typeof(IService))))
                .Where(i => !i.IsEquivalentTo(typeof(IFacade))
                    && !i.IsEquivalentTo(typeof(ICoreModel))
                    && !i.IsEquivalentTo(typeof(IDao))
                    && !i.IsEquivalentTo(typeof(ICoreController<>))))
            {
                registry.For(inter).Use(new ProxyInstance(type));
            }
        }
    }
}
